package com.fiximusic.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.fiximusic.common.Constant;
import com.fiximusic.dao.SingerMapper;
import com.fiximusic.dao.SongMapper;
import com.fiximusic.entities.Singer;
import com.fiximusic.entities.Song;

@Service
public class HomeService {

	@Resource
	SongMapper som;
	
	@Resource
	SingerMapper sim;
	
	@Value("${system.fileupload.path}")
	private String upload;
	
	/**
	 * 获取前十的歌曲
	 * @return
	 */
	public List<Song> getSongsPre10() {
		return som.getSongsPre10( Constant.STATE_NORM);
	}

	/**
	 * 获取前十的歌手
	 * @return
	 */
	public List<Singer> getSingersPre10() {
		return sim.getSingersPre10( Constant.STATE_NORM);
	}

	/**
	 * 得到搜索结果
	 * @param s
	 * @return
	 */
	public Object getSearchRs(Song s) {
		return som.getSearchRs(s);
	}

	/**
	 * 根据主键获取音乐
	 * @param id 
	 * @return
	 */
	public Song getSongByPri(String id) {
		return som.selectByPrimaryKey( id);
	}

	/**
	 * 插入歌手信息
	 * @param singer
	 */
	public int insertSinger(Singer singer) {
		return sim.insertSelective( singer);
	}

	/**
	 * 插入歌曲信息
	 * @param song
	 */
	public int insertSong(Song song) {
		return som.insertSelective( song);
	}

	/**
	 * 得到歌手信息
	 * @param singer
	 * @return
	 */
	public Singer getSinger(Singer singer) {
		return sim.getSinger( singer);
	}
}
